package com.guoheng.hazard.sys.controller.entpr;

import com.guoheng.hazard.common.base.Result;
import com.guoheng.hazard.sys.model.dto.entpr.EntprBasicInfoAddInDTO;
import com.guoheng.hazard.sys.model.dto.entpr.EntprBasicInfoUpdateInDTO;
import com.guoheng.hazard.sys.service.entpr.EntprBasicInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;

/**
 * 类功能描述:　EntprBasicInfoController
 *
 * @author fbl
 * @date 2019-29-11 14:29
 */
@RestController
@Validated
@Api(value = "企业基本信息")
public class EntprBasicInfoController {

    @Resource
    EntprBasicInfoService entprBasicInfoService;

    @ApiOperation(value = "查询单个企业基本信息")
    @GetMapping(value = "data/basic/enterprise/{entprId}")
    public Result getEntprBasicInfo(@PathVariable @NotNull @Positive Long entprId) {
        return entprBasicInfoService.getEntprBasicInfo(entprId);
    }

    @ApiOperation(value = "批量查询企业基本信息")
    @GetMapping(value = "data/basic/enterprises")
    public Result getEntprBasicInfos(String entprName, @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize) {
        return entprBasicInfoService.getEntprBasicInfos(entprName, pageNum, pageSize);
    }

    @ApiOperation(value = "新增企业基本信息")
    @PostMapping(value = "data/basic/enterprise")
    public Result addEntprBasicInfo(@RequestBody @Valid EntprBasicInfoAddInDTO entprBasicInfoAddInDTO) {
        return entprBasicInfoService.addEntprBasicInfo(entprBasicInfoAddInDTO);
    }

    @ApiOperation(value = "修改企业基本信息")
    @PutMapping(value = "data/basic/enterprise/{entprId}")
    public Result updateEntprBasicInfo(@PathVariable Long entprId, @RequestBody @Valid  EntprBasicInfoUpdateInDTO entprBasicInfoUpdateInDTO) {
        return entprBasicInfoService.updateEntprBasicInfo(entprId, entprBasicInfoUpdateInDTO);
    }

    @ApiOperation(value = "删除企业基本信息")
    @DeleteMapping(value = "data/basic/enterprise/{entprId}")
    public Result deleteEntprBasicInfo(@PathVariable @NotNull @Positive Long entprId) {
        return entprBasicInfoService.deleteEntprBasicInfo(entprId);
    }

    @ApiOperation(value = "搜索企业基本信息")
    @GetMapping(value = "data/basic/enterprise/search")
    public Result searchEntprBasicInfo(String entprName, Integer reviewStatus, @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize) {
        return entprBasicInfoService.searchEntprBasicInfo(entprName, reviewStatus, pageNum, pageSize);
    }

    @ApiOperation(value = "统计企业基本信息")
    @GetMapping(value = "data/basic/enterprise/statistics")
    public Result statisticsEntprBasicInfo() {
        return entprBasicInfoService.statisticsEntprBasicInfo();
    }

    @ApiOperation(value = "企业最近一次审核记录")
    @GetMapping(value = "data/basic/enterprise/lastExamine")
    public Result lastExamine(@NotNull @Valid Long entprId) {
        return entprBasicInfoService.lastExamine(entprId);
    }

}